package com.ls.pattern.interpreter.constants;

/**
 * 符号枚举
 *
 * @author 挥之以墨
 */
public enum SymbolEnum {
    /**
     * 符号对象及数学符号
     */
    ADD("+"),
    SUB("-"),
    MUL("*"),
    DIV("/"),
    LEFT_BRACKET("("),
    RIGHT_BRACKET(")");

    private String symbol;

    SymbolEnum(String symbol) {
        this.symbol = symbol;
    }

    public String getSymbol() {
        return symbol;
    }

    public static SymbolEnum getBySymbol(String symbol){
        for (SymbolEnum symbolEnum : SymbolEnum.values()) {
            if (symbol.equals(symbolEnum.getSymbol())){
                return symbolEnum;
            }
        }
        return null;
    }
}
